<?php

namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Session;
use think\Request;
class OrderComment extends Controller{
    /****
     * Class register          	      订单评论
     * @$post['order_id']             订单id
     * @$post['courier_id']        	  快递员id
     * @$post['content']              类型：0=差评，1=一般，2=好评
     * @$post['serve_grade']          店铺评分
     * @$post['superior_id']          上级id
     * @$post['taste_grade']          味道评分
     * @$post['pack_grade']           包装评分
     * @$post['manner_grade']         服务评分
     * @$post['like']                 0=差，1=点赞
     * @$post['anonymity']            状态：0=匿名，1=不匿名
     * @$post['image']                评论图片

     * @date                	        2020/06/03 
     * @package application\index\controller\OrderComment
    */
    public function index(){
      $post = input('post.');
      $data_courier=[
        'order_id'    =>$post['order_id'],,
        'courier_id'  =>$post['courier_id'],,
        'content'     =>$post['content'],
        'addtime'     =>time(),
      ];
      $order_courier = Db::name('order_courier')->insert($data_courier);
      if(!$order_merchant){
         $arr = [
           'state'      => 0,
           'message'    => "请求成功"
        ];
        return json($arr);
      }
      $data_merchant=[
        'order_id'      =>$post['order_id'],,
        'content'       =>$post['content'],,
        'serve_grade'   =>$post['serve_grade'],
        'superior_id'   =>$post['superior_id'],
        'taste_grade'   =>$post['taste_grade'],
        'pack_grade'    =>$post['pack_grade'],
        'manner_grade'  =>$post['manner_grade'],
        'like'          =>$post['like'],
        'anonymity'     =>$post['anonymity'],
        'image'         =>$post['image'],
        'addtime'       =>time(),
      ];
      $order_merchant= Db::name('order_merchant')->insert('data_merchant');
      if($order_merchant){
         $arr = [
           'state'      => 1,
           'message'    => "请求成功"
        ];
      }else{
        $arr = [
           'state'      => 0,
           'message'    => "请求成功"
        ];
      }
        return json($arr);
    }

}
